<?php
include("./config/session-action.php");
include("./config/config.inc.php");
include("./config/QuickMySQL.php");
include("./config/function.inc.php");

/*发送邮件处理类*/
class CSendEMailLastAction extends JsonBase
{
	/* 删除队列 */
	function OnDelete(){
		if(!isset($_POST['to'])){
			$this->json["msg"] = "参数错误";
			return;
		}
		$id = str_replace("'", "''", $_POST['to']);
		$sql = "delete from t_sendemail_notify where sm_to='{$id}'";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "删除ID为{$id}的群发队列成功";
		} else {
			$this->json["msg"] = "删除失败";
		}
	}
	/* 启动队列 */
	function OnStart(){
		if(!isset($_POST['to'])){
			$this->json["msg"] = "参数错误";
			return;
		}
		$id = str_replace("'", "''", $_POST['to']);
		$sql = "update t_sendemail_notify set sm_run=1 where sm_to='{$id}'";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "启动ID为{$id}的群发队列成功";
		} else {
			$this->json["msg"] = "启动失败";
		}		
	}
	/* 停止队列 */
	function OnStop(){
		if(!isset($_POST['to'])){
			$this->json["msg"] = "参数错误";
			return;
		}
		$id = str_replace("'", "''", $_POST['to']);
		$sql = "update t_sendemail_notify set sm_run=0 where sm_to='{$id}'";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "停止ID为{$id}的群发队列成功";
		} else {
			$this->json["msg"] = "停止失败";
		}		
	}
}

set_time_limit(0);
/*发送邮件操作*/
$cc = new CSendEMailLastAction();

?>